package com.atguigu.exceptionHandler;

import com.atguigu.exception.LoginException;
import com.atguigu.spzx.model.vo.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.io.IOException;

/**
 * @author dyl
 * @version 1.0
 * @description:
 * @date 2024/12/24 20:02
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
//    @ExceptionHandler(LoginException.class)
//    public Result loginExceptionHandler(LoginException e) {
//        log.error(e.getResultEnum().getMessage());
//        Integer code = e.getResultEnum().getCode();
//        String message = e.getResultEnum().getMessage();
//        return Result.build(code, message, null);
//    }

    @ExceptionHandler(Exception.class)
    public Result ExceptionHandler(Exception e) {
        log.error(e.getMessage());
        return Result.failed(e.getMessage());
    }
}
